package com.huluobo.a2110mvpimdemo.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.huluobo.a2110mvpimdemo.R;
import com.hyphenate.chat.EMGroup;

import java.util.List;

/**
 * Created by LC on 2023/12/16.
 */
public class FindJoinedGroupAdapter extends BaseQuickAdapter<EMGroup, BaseViewHolder> {
    public FindJoinedGroupAdapter(@Nullable List<EMGroup> data) {
        super(R.layout.item_find_joined_group, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, EMGroup emGroup) {
        baseViewHolder.setText(R.id.item_findGroup_name, emGroup.getGroupName());
        baseViewHolder.findView(R.id.item_findGroup_toChat).setOnClickListener(v -> {
            onJoinClick.onJoinClick(emGroup.getGroupId());
        });
    }

    public interface OnJoinClick {
        void onJoinClick(String groupId);
    }

    private OnJoinClick onJoinClick;

    public void setOnJoinClick(OnJoinClick onJoinClick) {
        this.onJoinClick = onJoinClick;
    }
}
